// =================================================================
// File: Inode.h
// Desc: Contains Inode class
// =================================================================

#ifndef INODE_H
#define INODE_H

// =================================================================
// INCLUDES
// =================================================================

#include <ctime>
#include <cstring>
#include "config.h"

// =================================================================
// CLASSES
// =================================================================

// =================================================================
// Name: Inode
// Desc: Contains bookkeeping information for file
// =================================================================
class Inode
{
  public:
    Inode(int size, 
        int num_blocks, 
        int num_links, 
        time_t accessed,
        time_t modified,
        time_t changed,
        int block_locations[NUM_BLOCK_LOCATIONS]);
    Inode();
    ~Inode();

    // Set/Get block location
    void SetBlockLocations(int block_locations[NUM_BLOCK_LOCATIONS]) {
      memcpy(this->block_locations, block_locations, sizeof(int)*NUM_BLOCK_LOCATIONS);
    }
    void SetBlockLocation(int index, int value) {
      block_locations[index] = value;
    }
    int GetBlockLocation(int index){
      return block_locations[index];
    }
    void SetAccessed(time_t accessed) {
      this->accessed = accessed;
    }
    void SetChanged(time_t changed) {
      this->changed = changed;
    }
    void SetModified(time_t modified) {
      this->modified = modified;
    }
    void SetNumBlocks(int num_blocks) {
      this->num_blocks = num_blocks;
    }
    void SetNumLinks(int num_links) {
      this->num_links = num_links;
    }
    void SetSize(int size) {
      this->size = size;
    }
    time_t GetAccessed() const {
      return accessed;
    }
    int* GetBlockLocations() {
      return block_locations;
    }
    time_t GetChanged() const {
      return changed;
    }
    time_t GetModified() const {
      return modified;
    }
    int GetNumBlocks() const {
      return num_blocks;
    }
    int GetNumLinks() const {
      return num_links;
    }
    int GetSize() const {
      return size;
    }


  private:

    int size;	        // num of bytes in file
    int num_blocks;
    int num_links;
    time_t accessed;	// file last viewed
    time_t modified;	// file contents changed
    time_t changed;		// inode changed
    int block_locations[NUM_BLOCK_LOCATIONS];	// 12 direct blocks,
    // 1 singly indirect, 1 doubly indirect, 1 triply indirect
};

#endif // INODE_H
